package string;
/**
 * String和StringBuilder对比
 */
public class StringStringBuilderDemo {
    public static void main(String[] args) {
        StringBuilder builder = new StringBuilder("a");
        for(int i=0;i<10000000;i++){
            builder.append(i);
        }
        System.out.println("继续执行");

        /*
        //String不适合频繁修改内容(效率低)
        String s= "a";
        for(int i=0;i<10000000;i++){
            s += i; //每次修改都会在内存中分配新的对象
        }
        System.out.println("继续执行");
        */
    }
}
